package cn.lisens.async.web;

import java.time.LocalDate;
import java.util.Date;

import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DateTestController {
	
//	@InitBinder
//    protected void initBinder(WebDataBinder binder) {
//        binder.addCustomFormatter();
//    }

	@GetMapping("/date")
    public String getEvents(LocalDate startDate, 
                            Date eventTime) {
        // Spring 会自动使用上面配置的格式来解析 "startDate" 和 "eventTime" 参数
        return "Start date: " + startDate + ", Event time: " + eventTime;
    }
	
	@GetMapping("/date2")
    public Date getEvents(Date eventTime) {
        return eventTime;
    }
}
